import React, { useState } from 'react'
import './register.css'
import { useNavigate } from 'react-router-dom';
import { Cell, Input, Button,  Dialog} from 'react-vant';
import { Docheckphone } from '../../axios';
export default function Step1() {
  let navigate = useNavigate()
  let [ tel,setTel ] = useState('')
  const res = () => {
    // console.log(111);
    Docheckphone({tel:tel}).then(res => {
      // console.log(res);
      if(res.data.message === "继续注册"){
         Dialog.confirm({
          title: '提示',
          message: `向手机号${tel}发送短信验证码`,
        }).then(()=>{
          navigate('/register/step2/'+tel)
        }).catch(() =>{
          // console.log(222);
        })
      }
    })
  }
  
  return (
    <div className='res-box1'>
      
      <Cell className='res-ipt'>
        <Input
         prefix="手机号"
          value={tel}
          type='tel'
          onChange={tel => setTel(tel)}
          placeholder='请输入手机号'
        />
      </Cell>
    <Button disabled={tel.length < 11 ? 'disabled' : ''}  className='res-btn' block type='submit' size='large' onClick={res}>下一步</Button>
    
    </div>
  )
}
